package otaku.gateway.core;

import io.netty.handler.codec.http.FullHttpRequest;

import java.net.InetSocketAddress;
import java.util.List;

public class PathUpstreamRequestMatcher implements UpstreamRequestMatcher {
    private final String prefix;
    private final List<InetSocketAddress> upstreamTargets;

    public PathUpstreamRequestMatcher(String prefix, List<InetSocketAddress> upstreamTargets) {
        this.prefix = prefix;
        this.upstreamTargets = upstreamTargets;
    }

    @Override
    public boolean match(FullHttpRequest request) {
        return request.uri().startsWith(prefix);
    }

    @Override
    public List<InetSocketAddress> getUpstreamTargets() {
        return upstreamTargets;
    }
}
